import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { Alphair } from './app.component';

import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TestPage } from '../pages/test/test';
import { TabsPage } from '../pages/tabs/tabs';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Dialogs } from '@ionic-native/dialogs';
import { Camera } from '@ionic-native/camera';
import { Observable } from 'rxjs/Observable';
import { LoginPage } from '../pages/login/login';
import { SignupPage } from '../pages/signup/signup';
import { NewPasswordPage } from '../pages/new-password/new-password';
import { UsermodifyPage } from '../pages/usermodify/usermodify';
import { GetVerificationCodePage } from '../pages/get-verification-code/get-verification-code';
import { HttpModule } from '@angular/http';

import {MqttMessage,MqttModule,MqttService} from 'ngx-mqtt';

import { HttpServiceProvider } from '../providers/http-service/http-service';
import { UdpServiceProvider } from '../providers/udp-service/udp-service';
import { MqttServiceProvider } from '../providers/mqtt-service/mqtt-service';
import { CommServiceProvider } from '../providers/comm-service/comm-service';
import { UsrInfoProvider } from '../providers/usr-info/usr-info';
import { AirkissProvider } from '../providers/airkiss/airkiss';

export const MQTT_SERVICE_OPTIONS = {
 connectOnCreate: true,
 hostname: 'iotplc.cn',
 port: 8083,
 path: '/mqtt'
};

export function mqttServiceFactory() {

   return new MqttService(MQTT_SERVICE_OPTIONS);

}

@NgModule({
  declarations: [
    Alphair,
    AboutPage,
    ContactPage,
    HomePage,
    TestPage,
    TabsPage,
    LoginPage,
    SignupPage,
    NewPasswordPage,
    GetVerificationCodePage,
    UsermodifyPage
  ],
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(Alphair),
    MqttModule.forRoot({
      provide: MqttService,
      useFactory: mqttServiceFactory
    })
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    Alphair,
    AboutPage,
    ContactPage,
    HomePage,
    TestPage,
    TabsPage,
    LoginPage,
    SignupPage,
    NewPasswordPage,
    GetVerificationCodePage,
    UsermodifyPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    Dialogs,
    Camera,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    HttpServiceProvider,
    UdpServiceProvider,
    MqttServiceProvider,
    CommServiceProvider,
    UsrInfoProvider,
    AirkissProvider,
  ]
})
export class AppModule {}
